/**
 * memcached单例
 * @author xialeistudio
 * @date 2016/5/9 0009
 */
'use strict';
const Memcached = require('memcached')
		, configManager = require('./config')
		, logger = require('./logger')
		, Promise = require('bluebird');
Promise.promisifyAll(Memcached.prototype);
const memcached = new Memcached(configManager.loadConfig().memcached.servers, configManager.loadConfig().memcached.options);
logger.info('[Memcached] initialized');
memcached.on('failure', (details)=> {
	logger.warn('[Memcached] ' + details.server + ' dead, ' + details.message.join(''));
});
module.exports = ()=> {
	return memcached;
};